package com.gome.han.cloud.client;



import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author hanpeng
* @version 创建时间：2020年8月8日 下午12:57:45
* @ClassName 类名称
* @Description 类描述
*/
@SpringBootApplication
@RestController
@EnableEurekaClient
public class Application {
	@Autowired
	private DiscoveryClient discoveryClient;
	
	@RequestMapping("/")
    public String home(String name) {
		//
		List<ServiceInstance> instances = this.discoveryClient.getInstances("spring-cloud-provider1");
		ServiceInstance service=instances.get(0);
		Map<String, String> metadata = service.getMetadata();
		System.out.println(metadata);
        return "Hello world";
    }

	public static void main(String[] args) {
		SpringApplication.run(Application.class);
	}
	
}
